<cfscript>    
    view = createObject("component", session.rootDir & ".views.layout");
    if( Session.Auth EQ True and (Session.strAuthType EQ Session.MANAGERS or Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR) ){
		view.init("Step 2:  HR - Termination Acknowledge",
			"/jquery/ui-1.8.5/jquery-ui.min.js,/jquery/plugins/scrollTo/jquery.scrollTo-1.4.2-min.js, /" & session.rootDir & "/static/js/SCF/Step2-HRAcknowledgeRequest.js",
			"/jquery/ui-1.8.5/themes/cupertino/jquery-ui.css","Home",main, "Termination");
    }else{
        view.init("Denied","","","Home","Denied");
    }    
    view.html();
</cfscript>

<cffunction name="main" access="public" output="true" returntype="any">
    <cfparam default="-1" name="url.TermReqID" />
    <cfscript>
        import models.*;
        FormAction = '/' & session.rootDir & '/controller/SubmitHandlerTermination.cfm?SCFStep2=update';
        FormReject = FormReject = '/' & session.rootDir & '/controller/SubmitHandlerTermination.cfm?SCFStep2=reject';
        FileDirectory = '/#session.TerminationDocuments#';
        KronosQueries = CreateObject("component", session.rootDir & ".DatabaseQueries.Kronos");
        TermRequest = entityLoadByPK("TerminationRequests", URL.TermReqID);
        Rosetta = EntityLoad("RosettaStone", TermRequest.getRosettaID());
        StepAction = ORMExecuteQuery("FROM StepActions WHERE TermReqID = ? AND StepID = 20", [URL.TermReqID] );
        StepAction = StepAction[1];     
        GetTermTypes = KronosQueries.funcGetPersonCodes('TT');
        GetES = KronosQueries.funcGetPersonCodes('ES');
        GetRC = KronosQueries.funcGetReasonCodes('ES');
    </cfscript>
    
    <cfquery name="GetEmpStatus" dbtype="query">
        Select * 
        From GetES
        Where PersonCodeIDNo in (-10133, -10132)
    </cfquery>
    
    <cfquery name="GetESReasonCodes" dbtype="query">
         Select * 
         From GetRC
        Where ReasonCodeIDNo not in (3,5,6,56)
    </cfquery>
    
    
    <cfoutput> 
    <h1 class="title">Step 2:  HR - Termination Acknowledge</h1>
        <div class="entry">    
            Welcome, #Session.EmpInfo.FirstName# #Session.EmpInfo.LastName#.  
            In this step, we'll capture information necessary to initiate the 
            request for termination of an employee:
            <br /><br /> 

            <cfform name="frmStep2" method="post" action="#FormAction#">

                <table width = 100%>
                    <tr>
                        <td width="27%">Submitted By:</td>
                        <td>
                            <cfset getEmployee = KronosQueries.funcGetCurrentEmployees( StepAction.getActionByID() ) />
                            <cfset setFullName = '#getEmployee.FirstName# #getEmployee.LastName#' />
                            #getEmployee.FirstName# #getEmployee.LastName#
                            <cfinput type="hidden" name="ManagerName" value="#setFullName#"/>
                        </td>
                    </tr>
                    <tr>
                        <td>Submitted Date/Time:</td>
                        <td>
                            #dateformat(StepAction.getCreationTimeStamp(),'mm/dd/yyyy') & ' ' & timeformat(StepAction.getCreationTimeStamp(),'HH:MM:ss TT')#
                            <cfinput type="hidden" name="DateSubmitted" value="#dateformat(StepAction.getCreationTimeStamp(),'mm/dd/yyyy') & ' ' & timeformat(StepAction.getCreationTimeStamp(),'HH:MM:ss TT')#"/>
                        </td>
                    </tr>
                    <tr>
                        <td valign="top">Comments:</td>
                        <td>
                            #StepAction.getNotes()#
                            <cfinput type="hidden" name="ManagerComments" value="#StepAction.getNotes()#"/>
                        </td>
                    </tr>
                    <tr>
                        <td colspan=2><HR /></td>
                    </tr>
                    <tr>
                        <td >Employee:</td>
                        <td>
                            <cfset getEmployee = KronosQueries.funcGetCurrentEmployees( TermRequest.getRosettaID() ) />
                            <cfset setFullName = '#getEmployee.FirstName# #getEmployee.LastName#' />
                            #getEmployee.FirstName# #getEmployee.LastName#
                        </td>
                    </tr>
                    <tr>
                        <td>Supervisor:</td>
                        <td>
                            <cfset getEmployee = KronosQueries.funcGetCurrentEmployees( TermRequest.getRosettaID() ) />
                            <cfset getSupervisor = KronosQueries.funcGetCurrentEmployeeByID( getEmployee.SupervisorIdNo ) />
                            <cfset setFullName = '#getSupervisor.FirstName# #getSupervisor.LastName#' />
                            #getSupervisor.FirstName# #getSupervisor.LastName#
                        </td>
                    </tr>
                    <tr>
                        <td >Division:</td>
                        <td>
                            <cftry>
                                <cfset getEmployee = KronosQueries.funcGetCurrentEmployees( TermRequest.getRosettaID() ) />
                                #getEmployee.Division#                            
                            <cfcatch type="Any" >
                                [Not Found]
                                <cfmail to='bfrick@scf.cc' From="EPAR_Error@scf.cc" subject="EPAR Term Step 2 ERROR" type="html">                    
                                    <cfdump var="#CFCATCH#">
                                </cfmail>
                            </cfcatch>
                            </cftry>

                        </td>
                    </tr>
                    <tr>
                        <td >Department:</td>
                        <td>
                            <cftry>
                                <cfset getEmployee = KronosQueries.funcGetCurrentEmployees( TermRequest.getRosettaID() ) />
                                #getEmployee.Department# 
                            <cfcatch type="Any" >
                                [Not Found]
                                <cfmail to='bfrick@scf.cc' From="EPAR_Error@scf.cc" 
                                    subject="EPAR Term Step 2 ERROR" type="html">                    
                                    <cfdump var="#CFCATCH#">
                                </cfmail>
                            </cfcatch>
                            </cftry>

                        </td>
                    </tr>
                    <tr>
                        <td>Termination Type:</td>
                        <td>                        
                            <cfselect name="TermTypeID" query="GetTermTypes" tabindex="20" value="PersonCodeIDNo" display="PersonCode" selected="0"/>
                        </td>
                    </tr>
                    <tr>
                        <td>Employee Status:</td>
                        <td>                        
                            <cfselect name="EmpStatusIDNo" query="GetEmpStatus" tabindex="30" value="PersonCodeIDNo" display="PersonCode" 
                            selected="#TermRequest.getEmpStatusIDNo()#"/>
                        </td>
                    </tr>
                    <tr>
                        <td nowrap="nowrap">Employment Status Reason:</td>
                        <td>                        
                            <cfselect name="EmpStatusReasonCode" query="GetESReasonCodes" tabindex="40" value="ReasonCodeIDNo" display="ReasonCode" 
                            selected="#TermRequest.getEmpStatusReasonCode()#"/>
                        </td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>
                            <cfinput type="checkbox" name="RehireElig" tabindex="45"  checked="yes"> Rehire Eligible
                        </td>
                    </tr>
                    <tr>
                        <td valign="top" title="AD account, home folder archive, email archive.">
                            Effective Termination Date*: <BR />
                        </td>
                        <td>
                            <div id="DateOfTermination_datepicker" ></div>
                            <cfif TermRequest.getTermDate() EQ "" OR TermRequest.getTermDate() EQ 'NULL'>
                                <cfset td = '#Now()#' />
                            <cfelse>
                                <cfset td = TermRequest.getTermDate() />
                            </cfif>
                            <cfinput type="hidden" name="TermDate" 
                                error_message="Please provide the Termination Date." value="#dateformat(td,'mm/dd/yyyy')#" >
                        </td>
                    </tr>
                    <tr>
                        <td valign="top" title="HR disable, HR Kronos username changed.">
                            HR Termination Date*: <BR />
                        </td>
                        <td>
                            <div id="SysDateOfTermination_datepicker"></div>
                            <cfif TermRequest.getSysTermDate() EQ "" OR TermRequest.getSysTermDate() EQ 'NULL'>
                                <cfset std = '#Now()#' />
                            <Cfelse>
                                <cfset std = TermRequest.getSysTermDate() />
                            </cfif>
                            <cfinput type="hidden" name="SysTermDate" 
                                error_message="Please provide the Termination Date." value="#dateformat(std,'mm/dd/yyyy')#" >
                        </td>
                    </tr>
                    <tr>
                        <td valign="top">Comments</td>
                        <td>
                            <cftextarea rows="2" tabindex="70" name="Comments" style="width:90%" value="" />
                        </td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td colspan="5" align="right">
                            <cfinput type="hidden" name="StepID" value="#StepAction.getStepActionsID()#" />
                            <cfinput type="hidden" name="TermReqID" value="#url.TermReqID#" />
                            <cfinput type="hidden" name="RosettaID" value="#TermRequest.getRosettaID()#" />
                            <cfinput type="hidden" name="FormReject" value="#FormReject#" />
                            <cfinput type="hidden" name="FormAction" value="#FormAction#" />
                            <cfinput type="button" name="Reject" value="Reject" tabindex="80">
                            <cfinput type="button" name="Submit" value="Next >>" tabindex="80">
                        </td>
                    </tr>
                </table>
            
        </cfform>
        </div>    
    </cfoutput>
    
</cffunction>